package com.stone.design.patterns.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @description
 * @Time 2018/4/12 9:59
 * Created by Stone on 2018/4/12.
 */

public class ConcreteAggregate<T> implements Aggregate<T> {

    List<T> lists = new ArrayList<>();
    @Override
    public void add(T obj) {
        lists.add(obj);
    }

    @Override
    public boolean remove(T obj) {
        return lists.remove(obj);
    }

    @Override
    public Iterator<T> iterator() {
        return new ConcreteIterator<>(lists);
    }
}
